var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var port = 3030;

module.exports = {
  devtool: 'eval-source-map',
  entry:  __dirname + "/app/main.js",//唯一入口文件
  output: {
    path: __dirname+'/dist/js',//打包后的文件存放的地方
    filename: "[name].js",//打包后输出文件的文件名
    chunkFilename: "[name].js"
  },
  module: {
    loaders: [
      {
        test: /\.json$/,
        loader: "json"
      },
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'babel',//在webpack的module部分的loaders里进行配置即可
        query: {
          presets: ['es2015','react']
        }
      },
      {
        test: /\.css$/,
        loader: "style!css?modules!postcss"
      },
      {
        test: /\.less$/,
        loader: "style!css!less"
      },
    ]
  },
  postcss: [
    require('autoprefixer')
  ],
  plugins: [
    new HtmlWebpackPlugin({
      template: __dirname + "/app/index.html",//new 一个这个插件的实例，并传入相关的参数
    }),
    new webpack.HotModuleReplacementPlugin(),//热加载插件
    new webpack.ProvidePlugin({
        $: "jquery",
        jQuery: "jquery",
        "window.jQuery": "jquery"
    })
  ],
  devServer: {
    colors: true,
    historyApiFallback: true,
    inline: true,
    hot: true,
    port: port
  }
}



